<form action="{:U('contacts/add')}" method="post">
	<input type="hidden" name="r" value="{$r}"/>
	<input type="hidden" name="module" value="{$module}"/>
	<input type="hidden" name="id" value="{$id}"/>
	<input type="hidden" name="customer_id" value="{$id}"/>
	<table type="hidden" class="table table-hover">
		<tfoot>
			<tr>
				<td>&nbsp;</td>
				<td colspan="3" align="center"><input name="submit" class="btn btn-primary" type="submit" value="{:L('SAVE')}"/> &nbsp;<input class="btn" type="button" onclick="javascript:$('#dialog-contacts').dialog('close');" value="{:L('CANCEL')}"/></td>
			</tr>
		</tfoot>
		<tbody>
			<tr>
				<td class="tdleft" >{:L('NAME')}</td>
				<td><input class="user_input" type="text" name="name" id="name"></td>
				<td class="tdleft" >{:L('SEX')}</td>
				<td><input type="radio"  name="sex" value="1"/>{:L('MAN')} &nbsp;<input  type="radio"  name="sex" value="0"/>{:L('WOMAN')}</td>
			</tr>
			<tr>
				<td class="tdleft" >{:L('ALL_OF_THE_CONTACTS_CLICK_TO_SELECT')}</td>
				<td><input type="hidden" name="owner_role_id" id="owner_role_id" value="{$Think.session.role_id}"/><input type="text" name="owner_name" id="owner_name" value="{$Think.session.name}"/></td>
			<!-- 	<td class="tdleft" >{:L('BELONGS TO THE CUSTOMER')}(单击选择)</td>
				<td><input type="hidden" name="customer_id" id="customer_id" value="{$customer['customer_id']}"/><input type="text" name="customer_name" id="customer_name"value="{$customer.name}"/></td>  -->
			</tr>
			<tr>
				<td class="tdleft" >{:L('POSITION')}</td>
				<td>
					<input class="user_input"  type="text" name="post"/>
				</td>
				<td class="tdleft" >{:L('DEPARTMENT')}</td>
				<td>
					<input class="user_input"  type="text" name="department"/>
				</td>
			</tr>
			<tr>
				<td class="tdleft" >{:L('EMAIL')}</td>
				<td><input class="user_input" name="email" type="text" /></td>
				<td class="tdleft" >{:L('PHONE')}</td>
				<td><input class="user_input" name="telephone" type="text" /></td>
			</tr>
			<tr>
				<td class="tdleft" >{:L('CONTACT_ADDRESS')}</td>
				<td><input class="user_input" name="address" type="text"/></td>
				<td class="tdleft" >{:L('POSTCODE')}</td>
				<td><input class="user_input" name="zip_code" type="text"/></td>
			</tr>
			<tr>
				<td class="tdleft" >{:L('REMARK')}</td>
				<td colspan="3"><textarea rows="3" name="description" ></textarea></td>
			</tr>
		</tbody>
	</table>
</form>
<div id="dialog-message" title="{:L('SELECT_CONTACTS_OWMER')}">loading...</div>
<div id="dialog-message2" title="{:L('SELECT_THE_CONTACT_BELONGS_TO_THE_CUSTOMER')}">loading...</div>
<script type="text/javascript">
$("#dialog-message").dialog({
	autoOpen: false,
	modal: true,
	width: 600,
	maxHeight: 400,
	buttons: {
		"Ok": function () {
			var item = $('input:radio[name="owner"]:checked').val();
			var name = $('input:radio[name="owner"]:checked').parent().next().html();
			$('#owner_name').val(name);
			$('#owner_role_id').val(item);
			$(this).dialog("close");
		},
		"Cancel": function () {
			$(this).dialog("close");
		}
	},
	position: ["center", 100]
});
$("#dialog-message2").dialog({
	autoOpen: false,
	modal: true,
	width: 600,
	maxHeight: 400,
	buttons: {
		"Ok": function () {
			var item = $('input:radio[name="customer"]:checked').val();
			var name = $('input:radio[name="customer"]:checked').parent().next().html();
			$('#customer_name').val(name);
			$('#customer_id').val(item);
			$(this).dialog("close");
		},
		"Cancel": function () {
			$(this).dialog("close");
		}
	},
	position: ["center", 100]
});

$(function(){
	$("#owner_name").click(
		function(){
			$('#dialog-message').dialog('open');
			$('#dialog-message').load('{:U("user/listdialog")}');
		}
	);
	$("#customer_name").click(
		function(){
			$('#dialog-message2').dialog('open');
			$('#dialog-message2').load('{:U("customer/listdialog")}');
		}
	);	
});
</script>